# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=spdlog
pkgver=1.12.0
pkgrel=1
pkgdesc="Fast C++ logging library"
url="https://github.com/gabime/spdlog"
arch="all"
license="MIT"
makedepends="cmake fmt-dev samurai"
checkdepends="catch2-3"
subpackages="$pkgname-dev"
source="https://github.com/gabime/spdlog/archive/v$pkgver/spdlog-v$pkgver.tar.gz
	spdlog-1.12.0-tests.patch
	"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DSPDLOG_BUILD_BENCH=OFF \
		-DSPDLOG_BUILD_TESTS="$(want_check && echo ON || echo OFF)" \
		-DSPDLOG_SANITIZE_ADDRESS=OFF \
		-DSPDLOG_FMT_EXTERNAL=ON \
		-DSPDLOG_BUILD_SHARED=ON \
		-DSPDLOG_BUILD_EXAMPLE=OFF
	cmake --build build
}

check() {
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest --test-dir build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	sed -e 's|.*#define SPDLOG_FMT_EXTERNAL|#define SPDLOG_FMT_EXTERNAL|' \
		-i "$pkgdir"/usr/include/spdlog/tweakme.h
}

sha512sums="
db9a4f13b6c39ffde759db99bcdfe5e2dbe4231e73b29eb906a3fa78d6b8ec66920b8bd4371df17ae21b7b562472a236bc4435678f3af92b6496be090074181d  spdlog-v1.12.0.tar.gz
13c5acf1a69190e98b1e67d0684f5ba35fc794aba8dc1101ed73df3285ebb5c7d59414254bd5b47c950679479c7152799a8382bfab7659351a57ac24622d93a5  spdlog-1.12.0-tests.patch
"
